package com.tn.rtdata.performance;

import java.util.Collection;
import javax.swing.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.tn.rtdata.performance.ui.MainFrame;

/**
 * The performance application runner class.
 */
public class Runner
{
  private static final Logger LOGGER = LoggerFactory.getLogger(Runner.class);

  /**
   * Program entry point.
   */
  public static void main(String[] args)
  {
    try
    {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

      ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(args);

      final Collection<ClientDef> clientDefs = applicationContext.getBeansOfType(ClientDef.class).values();

      SwingUtilities.invokeLater(
        new Runnable()
        {
          @Override
          public void run()
          {
            new MainFrame(clientDefs);
          }
        }
      );
    }
    catch (Exception e)
    {
      LOGGER.error("An error occurred starting the application.", e);
      System.exit(0);
    }
  }
}
